<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>02Swift版本</title>

  <link href="../../css/semantic/semantic.min.css" rel="stylesheet">
  <link href="../../css/markdown.css" rel="stylesheet">
  <link href="../../css/wtxynavigation.css" rel="stylesheet">
  <script src="../../js/jquery.min.js"></script>
  <script type="text/javascript" src="../../js/include.js"></script>


  <style>
    body{padding-top:0;background:#f7f7f7}
    body>.ui.container{width:100%;padding:0}
    #project-title{background:#6e6e6e;width:100%;line-height:3.572rem;color:#fff;font-size:1.2rem}
    #project-title .title-wrap{font-weight:700;padding:0 12px;width:100%;max-width:1366px!important;min-width:900px;margin:0 auto}
    #project-title .left,#project-title right{display:inline-block}
    #project-title .right{float:right}
    #project-title .right .wiki-actions .menu{left:auto;right:0;margin-top:.4em!important}
    #wiki-preview-container{width:100%;max-width:1366px!important;min-width:900px;padding:0;border:1px solid #e3e9ed;border-top:0}
    #wiki-preview>.ui.segment{margin-top:0;padding:1rem;padding-left:0;border:0}
    .hover-places{display:inline-block}
    #page-detail{width:60%;margin:0 auto}
    #page-detail .title{font-weight:700;font-size:24px;padding:12px 0;border-bottom:1px solid #ccc}
    #page-detail .content{margin-top:15px}
    .content p{word-wrap:break-word}
    #wiki-parent,#wiki-title,#wikis{display:none}
    .ui.grid{padding:0!important}
    #ex-all{cursor:pointer;color:#537c8d}
  </style>
</head>
<body>
  <div class="ui container">
    <div id="project-title">
      <div class="title-wrap">
        <div class="left">
          <i class="icon eye"></i>
          文档预览:
          mianmSDK
        </div>
        <div class="right">
          Export by Gitee
        </div>
      </div>
    </div>

    <div class="ui container" id="wiki-preview-container">
      <div id="wiki-preview">
        <div class="ui segment">
          <div id="page-detail" class="markdown-body">
            <div class='title'>02Swift版本</div><div class='content'><h1>
<a id="swift版本和特性" class="anchor" href="#swift%E7%89%88%E6%9C%AC%E5%92%8C%E7%89%B9%E6%80%A7"></a>Swift版本和特性</h1>
<p><strong>关键词</strong>:</p>
<h1>
<a id="1-历史版本" class="anchor" href="#1-%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC"></a>1. 历史版本</h1>
<p><img src="images/01Swift01.png" alt="01Swift01"></p>
<ul>
<li>从<strong>2014</strong>年至今，已经有<strong>15</strong>个版本发布，其中<strong>5</strong>个大版本，<strong>10</strong> 个小版本</li>
<li>与之对比的是<strong>Objective-C</strong>从80年代至今，只有两个版本</li>
<li>2015年12月<strong>Swift</strong>正式<strong>开源</strong>，目前<strong>Swift</strong>可以应用到多个领域，甚至连<strong>TensorFlow</strong>也有<strong>Swift</strong> 语言版本</li>
</ul>
<h2>
<a id="11-swift-2" class="anchor" href="#11-swift-2"></a>1.1 Swift 2</h2>
<ul>
<li>
<p><strong>Error handling</strong>增强</p>
<ul>
<li>2.0之前还用<strong>NSError</strong>
</li>
</ul>
</li>
<li>
<p><strong>guard</strong>语法</p>
<ul>
<li>你希望得到的状态</li>
</ul>
</li>
<li>
<p>协议支持扩展</p>
</li>
</ul>
<h2>
<a id="12-swift-3" class="anchor" href="#12-swift-3"></a>1.2 Swift 3</h2>
<ul>
<li>新的<strong>GCD</strong>和<strong>Core Graphics</strong>
</li>
<li>
<strong>NS</strong>前缀从老的<strong>Foundation</strong>类型中移除
<ul>
<li>
<code>NSURL</code>,不用<code>NS</code>
</li>
</ul>
</li>
<li>内联序列函数<strong>sequence</strong>
</li>
<li>新增<strong>fileprivate</strong>和<strong>open</strong>两个权限控制</li>
<li>移除了诸多弃用的特性，比如**++<strong>、</strong>-- **(两个-)运算符等</li>
<li>....等等</li>
</ul>
<h2>
<a id="13-swift-4" class="anchor" href="#13-swift-4"></a>1.3 Swift 4</h2>
<ul>
<li>
<strong>extension</strong>中可以访问<strong>private</strong>的属性</li>
<li>
<strong>类型</strong>和<strong>协议</strong>的组合类型，</li>
<li>
<strong>Associated Type</strong>(关联类型)可以追加<strong>Where</strong>约束语句</li>
<li>新的<strong>Key Paths</strong>语法</li>
<li>下标支持泛型</li>
<li>字符串增强</li>
</ul>
<h2>
<a id="14-swift-5" class="anchor" href="#14-swift-5"></a>1.4 Swift 5</h2>
<ul>
<li>
<strong>ABI</strong>稳定</li>
<li><strong>Raw strings</strong></li>
<li>标准库新增<strong>Result</strong>
</li>
<li>定义了与<strong>Python</strong>或<strong>Ruby</strong>等脚本语言互操作的动态可调用类型</li>
</ul>
<h1>
<a id="答" class="anchor" href="#%E7%AD%94"></a>答:</h1></div>
          </div>
        </div>
      </div>
      </div>
  </div>
</body>
</html>